/*
 *
 * Copyright(c) 2010 Safelayer Secure Communications
 *
 * This is open source software, placed under the terms of the
 * GNU GENERAL PUBLIC LICENSE Version 3.
 * Please see: http://www.gnu.org/licenses/gpl-3.0.txt
 * 
 * Permission to use, copy, modify, and distribute this software
 * for any purpose and without fee is hereby granted, provided
 * that the above copyright notices appear in all copies and that
 * both the copyright notice and this permission notice appear in
 * supporting documentation.
 * 
 */
package com.neuralnoise.foaf.core;

import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;

/**
 * Name based smushing FOAF rule.
 * 
 * @author victor.martinez <swtp@safelayer.com>
 * 
 */
public class NameRule extends Rule {

	private Property propertyName;

	public NameRule() {
		super("Name");
		propertyName = FOAFVocabulary.name;
	}

	public boolean equals(Resource resource1, Resource resource2) {
		if (!resource1.hasProperty(propertyName) || !resource2.hasProperty(propertyName))
			return false;

		String name1 = resource1.getProperty(propertyName).getLiteral().toString();
		String name2 = resource2.getProperty(propertyName).getLiteral().toString();
		return name1.equals(name2);
	}

	@Override
	public boolean isTrustEquals() {
		return false;
	}

}
